package megrez.mail.sender.component.template;

import java.util.Map;

import org.springframework.stereotype.Component;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;

import lombok.RequiredArgsConstructor;

/**
 * Thymeleaf模板处理
 *  
 * @author Lucky Yang
 * @since 2.6.9
 */
@Component
@RequiredArgsConstructor
public class ThymeleafTemplateProcess implements TemplateProcess {
    private final TemplateEngine engine;

    @Override
    public String render(String template, Map<String, Object> params) {
        Context context = new Context();
        context.setVariables(params);
        return engine.process(template, context);
    }
    
}
